\section{matrix --- Convert to Matrix}
\label{fn:matrix}
\index{matrix()}
\index{convert to matrix}
\begin{rail}
Matrix : 'matrix' '(' ( () | Scalar | Matrix | String ) ')' ;
\end{rail}

The \verb+matrix+ function attempts to convert its argument
to a matrix.  If you pass no arguments, you get an empty matrix back.
If you pass a scalar or string argument, you get back a one element
matrix with the argument as that element.  If you pass a matrix
argument, you just get that matrix back.

\paragraph{Example}
\index{example of matrix()}
\index{matrix()!example}
\begin{verbatim}
> matrix()
        []
> matrix(3)
        3  
> show(matrix(3))
   name:      NULL  
   class:     num   
   type:      real  
     nr:      1     
     nc:      1     
> show(matrix("This is a test string"))
   name:      NULL    
   class:     string  
   type:      string  
     nr:      1       
     nc:      1       
> a = [2.4,5,3,6;2,-6,-9,102]
 a =
      2.4          5          3          6  
        2         -6         -9        102  
> matrix(a)
      2.4          5          3          6  
        2         -6         -9        102  
\end{verbatim}

See also: Page~\pageref{fn:scalar} \verb+scalar()+.

\newpage





